package com.paw.security.service;

import java.util.ArrayList;

import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

/**
 * @author lvzihai
 * @date 2021/7/13
 **/
@Service
public class DefaultUserDetailService implements UserDetailsService {

  @Override
  public UserDetails loadUserByUsername (String username) throws UsernameNotFoundException {
    // 从数据库中获取用户信息， 示例代码
    PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
    User user = new User(username,passwordEncoder.encode("123456"),new ArrayList<>());
    return user;
  }
}
